<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=8">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta content="B2B电商平台" name="description"/>
	<meta content="B2B电商平台" name="keyword"/>
	
	<title>B2B电商平台.店铺商品价格修改</title>
	<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
	<link rel="shortcut icon" href="include/images/icss.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/global.css" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
	<link rel="stylesheet" type="text/css"	href="<%=path %>/include/css/mmt_trading.css" />
	<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/icss.busin.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
	
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
	
	<style type="text/css">
		body{background:#ebebeb;font-size: 14px;padding-left: 0px !important;}
		.title_div{
			height: 81px;
			padding-top: 20px;
			text-align: center;
			//border-bottom: 3px solid #e0e0e0;
			background: #fff;
		}
		.titleCss{
			height: 65px;
			width: 790px;
			margin: 0 auto;
			background: url('<%=path %>/images/postTrade/post_trade_one.png') no-repeat 0 0;
		}
		.title_2{
			background-position: 0 -200px;
		}
		.mainDiv{
			margin: 10px auto;
			width: 1190px;
		}
		.nextDiv .button2{
		    font: 20px "Microsoft YaHei", "SimHei ";
	    	line-height: 63px;
    		width: 203px;
			background: url('<%=path %>/images/postTrade/pic-global.png') no-repeat -148px -558px;
			color: #fff;
		}
		.nextDiv button {
		    font: 16px "Microsoft YaHei", "SimHei ";
		    line-height: 30px;
		    width: 60px;
		    background: url('<%=path %>/images/postTrade/pic-global.png') no-repeat -150px -578px;
		    color: #fff;
		}
	    .subDiv{
	    	margin: 60px 0px 50px;
	    	height: 63px;
	    	text-align: center;
	    }
	    .nextDiv{
	    	/* width: 279px;
	    	height: 100%; */
	    	margin: 0px auto;
	    }
	    .main_div1{
	    	background:#fff; 
	    	height:48px;
	    	margin: 10px 80px;
	    	border-top: 4px solid #F75D5F;
	    	line-height: 48px;
	    	padding: 0px 10px;
	    }
	    .btCss{
	    	height: 22px;
    		width: 60px;
    		background: url('<%=path %>/images/postTrade/abtnBg.png');
    		float: left;
    		margin: 13px 0 0 20px;
    		font-size: 12px;    
    		line-height: 22px;
    		padding-left: 20px;
    		margin-left: 20px;
	    }
	    a {
		    color: #039;
		    text-decoration: none
	    }
	    ul,li{
	    	list-style: none;
	    }
	    .main_div1 li{
	    	float: left;
	    	font-size: 12px;
	    }
	    .saveDraftCss{
	    	float: right;
	    	border: 1px solid #cfcfcf;
	    	color:#333;
	    	line-height:28px;
	    	margin:10px 0px;
	    	padding: 0px 20px;
	    }
	    .saveDraftCss:hover {
	    	background: #ff8048;
	    	color:#fff;
	    	border: 1px solid #f67943;
	    }
	    .getDraftCss:hover {
	    	color:red;
	    }
	    .divCss_title{
	    	background: #fff;
		    height: 40px;
		    font: 18px/40px "Microsoft YaHei", "SimHei ";
		    text-indent: 10px;
		    border-bottom: 1px solid #d1d1d1;
		    color: #000;
		   
	    }
	    .tipH4{
	    	width:80px;
	    	float:left;
	    	font-weight: bold;
	    	line-height: 18px;
	    }
	    .cdyParaCss ul{
	    	width: 280px;border: 1px solid #c7c7c7;height: 22px;
	    }
	    .cdyParaCss ul li{
	    	display:none;
	    }
	    .tdL{
	    	text-align: right;width: 15%;padding-right: 5px;
	    }
	    .cdyParaCss .tdR{
	    	text-align: left;padding-left: 10px;vertical-align: middle;
	    }
	    .cdyParaCss .tdR div{
	    	width:280px;border: 1px solid #c7c7c7;height: 22px;
	    }
	    .cdyParaCss .tdR input{
	    	border: 0px;padding: 0px 3px;margin-top: -15px;width: 250px;
	    }
	    .cdyParaCss .tdR s,td div s,.addPrice_css{
    	    float: right;
		    width: 21px;
		    height: 22px;
		    background: url('<%=path %>/images/postTrade/pic-global.png') no-repeat -275px -275px;
	    }
	    .cdyParaCss .tdR select{
	    	appearance:none;-moz-appearance:none;-webkit-appearance:none;
	    	width: 282px;margin: 20px 0 0 -257px;position: absolute;overflow: auto;max-height: 200px;
	    }
	    .cdyParaCss .tdR select option{
	    	heigth:20px;padding:5px 3px 0px;
	    }
	    .cdyParaCss .tdR select option:hover{
	    	background: #ebebeb;
	    }
	    .borderCss{
	    	border-top: 1px dashed #ccc;margin: 20px 80px;padding-bottom: 5px;
	    }
	    .div_title_css{
	    	border: 0px;margin: 15px 80px 10px;white-space: nowrap;
	    }
	    .div_title_css table tr td{
	    	width: 16%;
	    }
	    .div_title_css table tr td input{
	    	width: 90%;height: 22px;
	    }
	    .div_title_css p{
	    	color: #999;padding: 10px 0px 10px 83px;white-space: normal;
	    }
	    .radioCss{
	    	margin: 0px;
	    }
	    .line_color_css td{
	    	border-top: 1px solid #c7c7c7;
	    }
	    .td1{
	    	width: 130px;text-align: right;padding-right: 10px;
	    }
	    .addPrice_css{
	    	height: 11px;
		    background-position: -478px -298px;
		    margin-top: 11px;
		    margin-left: 5px;
		    float: left;
	    }
	    .img_css{
	    	padding-right: 10%;float: left;width: 14%;margin-top: 20px;
	    }
	    .add_img_div{
	     	height: 102px;
    		width: 102px;
	    	background: url('<%=path %>/images/postTrade/addIco.png') no-repeat 0px -50px;
	    }
	    td {
	    	vertical-align: middle;
	    }
	    
	</style>
	<script type="text/javascript">
		var flag = "${flag}"; 
		var status = "${status}";
		var appFlag = "${appFlag}"; 
		$(function(){
			_baseVal2();
			_measuringInfo();	
			if(appFlag == 'apply'){
				$("#reason").attr("readonly","readonly");
			} 			
		});

		function _goBackPage(){//返回上一页
			window.location.href = "<%=path %>/postTrade/toPostTradeOnePage.do";
		}
		function _getDraftListPage(){//草稿列表页
			window.location.href = "<%=path %>/postTrade/toPostTradeOnePage.do";
		}
		function _saveDraftInfo(){//草稿列表页
			window.location.href = "<%=path %>/postTrade/toPostTradeOnePage.do";
		}
		function _selVal(para){//商品参数项搜索
			$("#sel0").css("display","");
			$("#sel0").size(6);
			$(".att0").css("border","1px solid #86b4f8");
			$(".att0 s").css("background-position", "-275px -308px");
		}
		/*_baseVal2： 价格区间 */		
		function _baseVal2(){			
			$.ajax({
				type:"post",
				url:'<%=path%>/productPrice/queryProductPriceInfo2.do',
				dataType:"json",
				data:{productId:"${productId}",status:"${ status}",passed:"${ passed}",uuid:"${uuid}"},
				success:function(data){
					if(data){
						var priceList = data.priceList2;
						_proPrice2(priceList);
					}
				}
			});
		}
		
		/* _proPrice、_proPrice2、_previewHtml：解析list，显示价格列表 */
		function _proPrice(list){
			for(var i=0;i<list.length;i++){
				var info = list[i];
				$("#tr"+i).css("display","");
				$("#buyNum"+i).val(info.purchaseLow);
				$("#price"+i).val(info.proPrice);
				_previewHtml(i+"",(i-1)+"");
			}
		}
		function _proPrice2(list){
			for(var i=0;i<list.length;i++){
				var info = list[i];
				$("#tr"+i).css("display","");
				$("#buyNum"+i).val(info.PURCHASE_LOW);
				$("#price"+i).val(info.PRODUCT_PRICE);
				$("#reason").val(info.REASON);
				_previewHtml(i+"",(i-1)+"");
			}
		}
		function _previewHtml(id1,id2){
			var bn = $("#buyNum"+id1).val();
			var price = $("#price"+id1).val();
			var measuring = $("#measuring").val();
			if(price == "" || bn == "") return;
			$("#yl").css("display","none");
			$("#preview"+id1).css("display","");
			var pHtml = price+" 元/"
			$("#preview"+id1+"2").text(pHtml);
			$(".unitVal").empty();
			 $(".unitVal").text(measuring);
			if(id1=="0"){
				$("#preview01").text("≥"+bn);
			}else{
				var bn1 = $("#buyNum"+id2).val();
				$("#preview"+id1+"1").text("≥"+bn);
				if(bn1 != ""){
					var num = parseInt(bn)-1;
					$("#preview"+id2+"1").text(bn1+"~"+num);
				}
				var price1 = $("#price"+id2).val();
				if(price1 != ""){
					pHtml = price1+" 元/"
					$("#preview"+id2+"2").text(pHtml);
				}
			}			
			_reHeight("rightFrame","contentDiv");
		}
		/* 添加 一行 */
		var num = 1
		function _addPrice(){
			var tr1 = $("#tr1").css("display");
			if("none"==tr1) $("#tr1").css("display","");
			else{
				 $("#price2").val("");
				 $("#buyNum2").val("");
				 $("#tr2").css("display","");
				 $("#addPrice").css("display","none");
			}
		}
		/* 删除 */
		function _delTr(id){
			var tr1 = $("#tr1").css("display");
			var tr2 = $("#tr2").css("display");
			if(id=="tr1"){
				if(tr2=="none"){ 
					$("#tr1").css("display","none");
					$("#price1").val("");
					$("#buyNum1").val("");
				}else{
					 $("#tr2").css("display","none");
					 $("#price1").val($("#price2").val());
					 $("#buyNum1").val($("#buyNum2").val());
				}
			}else{
				$("#tr2").css("display","none");
			}
			$("#addPrice").css("display","");
			$("."+id).css("display","none");
			id = id.charAt(id.length-1);
			if(id=="1"){
				var dis = $("#preview2").css("display");
				if(dis != "none")  $("#preview2").css("display","none");
				else $("#preview1").css("display","none");
				_previewHtml("0","0");
			}else{
				_previewHtml(id,"0");
			}
		}
		function _onbl(id1,v2,id3){
			var val1 = parseFloat($("#"+id1).val());
			var val3 = parseFloat($("#"+id3).val());
			var id = "p"+id1.charAt(id1.length-1);
			var bln = val3>=val1;
			if(id1.charAt(0)=="p") bln = val3 <= val1;
			var dis = $("#"+id).css("display");
			if(bln){
				$("#"+id).css("display","");
				$("#"+id+v2).css("display","");
			}else{
				$("#"+id).css("display","none");
				$("#"+id+v2).css("display","none");
			}
			_previewHtml(id1.charAt(id1.length-1),id3.charAt(id1.length-1));
		}
		//select下拉列表
		function _pullList(num,viewCode){
			var codeName = $("#codeName").val();
			$.ajax({
				type:"post",
				url:'<%=path%>/postTrade/queryDirectoryInfo.do',
				dataType:"json",
				//async:true,
				data:{viewCode:viewCode,codeName:codeName,flag:"1",viewFlag:"view"},
				success:function(data){
					if(data){						
						var arr = data.directoryList;
						var html = "";
						if(arr.length==1)
							html += "<select id='sel"+num+"' size='"+arr.length+"' class='att"+num+"' style='display:none;overflow: hidden;'>";
						else
							html += "<select id='sel"+num+"' size='"+arr.length+"' class='att"+num+"' style='display:none;'>";
						for(var i=0;i<arr.length;i++){
							var d = arr[i];
							html += "<option onclick=\"_clickOption('att"+num+"','"+d.CODE_NAME+"')\" value='"+d.CODE_NAME+"'>"+d.CODE_NAME+"</option>";
						}
						html += "</select>";
						$("#att"+num).after(html);
					}
				}
			});
		}

		function _changeVal(id){
			$("#codeName").val($("#"+id).val());
			id = id.replace("att","");
			var viewCode = $("#viewCode"+id).val();
			_pullList(id,viewCode);
		}
		
		function _clickInput(id){
			$("."+id).css("display","");
			$("."+id).css("border","1px solid #86b4f8");
			$("."+id+" s").css("background-position", "-275px -308px");
		}

		function _clickOption(id,val){
			$("#"+id).val(val);
			$("."+id).css("border","1px solid #c7c7c7");
			$("."+id+" s").css("background-position", "-275px -275px");
			id = id.replace("att","");
			$("#sel"+id).css("display","none");
			if(id=="measuring"){
				 $(".unitVal").empty();
				 $(".unitVal").text(val);
			}
		}
		//计量单位 flag: 2
		function _measuringInfo(){
			$.ajax({
				type:"post",
				url:'<%=path%>/postTrade/queryDirectoryInfo.do',
				dataType:"json",
				data:{flag:"2"},
				success:function(data){
					if(data){
						var arr = data.directoryList;
						var html = "";
						html += "<select id='selmeasuring' size='"+arr.length+"' class='measuring' style='display:none;overflow: hidden;margin:22px 0px 0px -150px;position: absolute;width:172px;'>";
						for(var i=0;i<arr.length;i++){
							var d = arr[i];
							html += "<option onclick=\"_clickOption('measuring','"+d.CODE_NAME+"')\" value='"+d.CODE_NAME+"'>"+d.CODE_NAME+"</option>";
						}
						html += "</select>";
						$("#measuring").after(html);
					}
				}
			});
		}
  	</script>
  </head>
  
  <body>
    <div id="contentDiv">
    	<input type="hidden" id="codeName" name="codeName">
    	<input type="hidden" id="flag" name="flag" value="${flag}">
    	<div class="title_div" style="display: none;">
	   		<div class="titleCss title_2"></div>
	    <hr color="#ebebeb" height="0.1px" style="margin-top:13px"/>
	   	</div>
	   	<div  class="colnums-2-ab-b" style="background:#fff;font-size: 12px;padding-bottom: 15px;">
	   			<div class="toptil">
	   			商品价格变更审核
	   				<c:if test="${status eq '0'}">[未提交]</c:if>
	   				<c:if test="${status eq '1'}">[待审核]</c:if>
	   				<c:if test="${status eq '2'}">[已通过]</c:if>
	   				<c:if test="${status eq '3'}">[未通过]</c:if>
	   			</div>
	   			<div style="padding:10px 0px 0px 20px;">
	   				<table style="width: 100%;line-height: 40px;">
	   					<tr>
	   						<td class="tdL" style="">商品名称：</td>
	   						<td class="tdR">${pro.proName }</td>
	   					</tr>
	   					<tr>
	   						<td class="tdL" style="">计量单位：</td>
	   						<td style="vertical-align: middle;">
	   							<div class="measuring">
		   							${pro.proUnit }
		   						</div>
	   						</td>
	   					</tr>
	   					<tr>
	   						<td class="tdL" style="">零售价：</td>
	   						<td>${pro.PRODUCT_RETAIL_PRICE }&nbsp;元
								<input type="hidden" id="productId" name="productId" value="${productId }">
	   						</td>
	   					</tr>
	   					<tr>
	   						<td class="tdL" style="">供应总量：</td>
	   						<td>
	   							<span id="proStock" style="padding-right: 120px;">${pro.stock }&nbsp;${pro.proUnit }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
	   						</td>
	   					</tr>
	   					<tr>
	   						<td class="tdL" style="">成本价格：</td>
	   						<td>
	   							<span id="proStock">${pro.cost }&nbsp;元</span>
	   						</td>
	   					</tr>
	   					<tr>
	   						<td class="tdL" style="">审核说明：</td>
	   						<td>
	   							<textarea id="reason" rows="3" cols="25" style="width:95%" placeholder="请输入审核说明，不超过85个字" <c:if test="${status != 1}">readonly="readonly"</c:if>></textarea>
	   						</td>
	   					</tr>
	   				</table>
	   			</div>
	   			<div class="subDiv">
					<div class="nextDiv">
					<c:if test="${status !=2 &&status != 3 &&appFlag != 'apply'}">
						<button id="bt1" onclick="audit(2)">通过</button>
						<button id="bt2" onclick="audit(3)">不通过</button>
					</c:if>
						<button id= "bt3" onclick="history.go(-1)">返回</button>
					</div>	
				</div>
				</div>
	   		</div>		   		
  </body>
  <script type="text/javascript">
  	
  	/* @param：status 0:不通过   1：通过 */
  	function audit(status){    		 		    
    		var reason = $("#reason").val();
    		if(reason.length==0){
    			alert("请输入审核说明");
    			return;
    		}
    		if(reason.length>85){
    			alert("审核说明输入超过85个字");
    			return;
    		}
    		$.ajax({
 	 		    type:"post",
 	 		    url: "<%=path%>/productPrice/audit.do",
 	 		    data: {productId:"${productId}",reason:reason,status:status},
 	 		  	dataType: "json",
 	 		    success:function(data){
 	 	 		    var result = data;
 	 	 		    if(result == '1'){
 	 	 		    	history.go(-1);
 	 	 		    }else if(result == '2'){
 	 	 		    	alert("服务器内部错误！");
 	 	 		    }
 	 	 		}
 	 		});
    	}
  </script>
</html>